package cn.eric.framework.log.log4j2;

public class Log4Framework {
    private static final String TEMPLATE = "[%s] : %s";
    private String title;
    private String info;
    private String errorReason;

    public static Log4Framework create(String title, String info) {
        return new Log4Framework(title, info);
    }

    public static Log4Framework create(String title, String info, String errorReason) {
        return new Log4Framework(title, info, errorReason);
    }

    private Log4Framework() {
    }

    private Log4Framework(String title, String info) {
        this.title = title;
        this.info = info;
    }

    private Log4Framework(String title, String info, String errorReason) {
        this.title = title;
        this.info = info;
        this.errorReason = errorReason;
    }

    @Override
    public String toString() {
        if (errorReason != null) {
            info += " : " + errorReason;
        }
        return String.format(TEMPLATE, title, info);
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getInfo() {
        return info;
    }

    public void setInfo(String info) {
        this.info = info;
    }

    public String getErrorReason() {
        return errorReason;
    }

    public void setErrorReason(String errorReason) {
        this.errorReason = errorReason;
    }
}
